package liuwanghui.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import liuwanghui.dto.request.UserQueryDTO;
import liuwanghui.dto.request.UserUpdateDTO;
import liuwanghui.pojo.Result;
import liuwanghui.service.AdminService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
@Tag(name = "管理员", description = "管理员相关接口")
public class AdminController {

    private final AdminService adminService;

    @GetMapping("/users")
    @Operation(summary = "获取用户列表")
    public Result getUserList(UserQueryDTO params) {
        return adminService.getUserList(params);
    }

    @GetMapping("/users/{id}")
    @Operation(summary = "获取用户详情")
    public Result getUserDetail(@PathVariable Long id) {
        return adminService.getUserDetail(id);
    }

    @PutMapping("/users/{id}")
    @Operation(summary = "更新用户信息")
    public Result updateUser(@PathVariable Long id, @RequestBody @Valid UserUpdateDTO dto) {
        adminService.updateUser(id, dto);
        return Result.success();
    }

    @PutMapping("/users/{id}/status")
    @Operation(summary = "更新用户状态")
    public Result updateUserStatus(@PathVariable Long id, @RequestParam String status) {
        adminService.updateUserStatus(id, status);
        return Result.success();
    }

    @GetMapping("/statistics/dashboard")
    @Operation(summary = "获取仪表盘统计")
    public Result getDashboardStatistics() {
        return adminService.getDashboardStatistics();
    }
} 